﻿using OSCSchema;

namespace OSC.Base
{
    public class Link : IActivityDetail, IListItem
    {
        private readonly string m_Name;
        private readonly string m_Url;
        private readonly string m_Text;

        public Link(string name, string url, string text)
        {
            m_Name = name;
            m_Url = url;
            m_Text = text;
        }

        public templateVariableType ToTemplateVariableType()
        {
            return new templateVariableType
                       {
                           name = m_Name,
                           text = string.IsNullOrEmpty(m_Text) ? m_Url : m_Text,
                           value = m_Url,
                           type = templateTypeRestrictionType.linkVariable
                       };
        }

        public simpleTemplateVariableType ToSimpleTemplateVariableType()
        {
            return new simpleTemplateVariableType
                       {
                           name = m_Name,
                           text = string.IsNullOrEmpty(m_Text) ? m_Url : m_Text,
                           type = templateSimpleTypeRestrictionType.linkVariable
                       };
        }
    }
}